<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="__ADMIN__css/font.css">
    <link rel="stylesheet" href="__ADMIN__css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__js/jq.js"></script>
    <script type="text/javascript" src="__ADMIN__lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="__ADMIN__html5.min.js"></script>
    <script src="__ADMIN__respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">模板管理</a>
        <a>
          <cite>模板管理</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div style="display: flex" class="layui-form">
        <input type="text"  id="fore_name" value="newTpl.html">
        <input type="hidden" id="size" value="{$size}">
        <button id="addfore" class="layui-btn">添加</button>
    </div>
    <script>
        $('#addfore').click(function () {
            var forename = $("#fore_name").val();
            var size = $("#size").val();
            $.ajax({
                type:'post',
                data:{forename:forename,size:size},
                dataType:'json',
                url:"{:url('admin/fore/makeFile')}",
                success:function (data) {
                    if (data.code == 0){
                        layer.msg(data.message, {icon: 6},function () {
                            location.replace(location.href);
                        });
                    }else{
                        layer.msg(data.message);
                    }
                }
            })
        })
    </script>
    <table class="layui-table">
        <thead>
        <tr>
            <th width="80%">模板名称</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name='htmlList' id='list'}
            <tr>
                <td>{$list}</td>
                <td>
                    <a  file="{$dir}{$list}"  class="layui-btn layui-btn-xs edit">编辑</a>
                    <a  file="{$dir}{$list}" class="layui-btn layui-btn-danger layui-btn-xs destory">删除</a>
                </td>
            </tr>
        {/volist}
        </tbody>
    </table>
</div>
<script>
    $(".edit").click(function () {
        var file = $(this).attr('file');
        var size = "{$size}";
        window.location.href="/admin/fore/edit?file="+file+'&size='+size;
    })
    $('.destory').click(function () {
        var file = $(this).attr('file');
        $.ajax({
            type:'post',
            data:{file:file},
            dataType:'json',
            url:"{:url('admin/fore/delete')}",
            success:function (data) {
                if (data.code == 0){
                    layer.msg(data.message, {icon: 6},function () {
                        location.replace(location.href);
                    });
                }
            }
        })
    })
</script>
</body>
</html>